package com.whw.springboot.bcucb.controller;

import com.whw.springboot.bcucb.entity.Message;
import com.whw.springboot.bcucb.entity.User;
import com.whw.springboot.bcucb.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "用户")
@RestController
@RequestMapping("/api/User")
public class UserController {

    @Resource
    private UserService userService;

    /**
     * 用户登录
     */
    @ApiOperation(value = "用户登录")
    @PostMapping(value = "/login")
    public Message<?> login(String user_id,String user_pwd){
        return userService.login(user_id,user_pwd);
    }


    /**
     * 管理员登录
     */
    @ApiOperation(value = "管理员登录")
    @PostMapping(value = "/login/admin")
    public Message<?> adminLogin(String user_id,String user_pwd){
        return userService.adminLogin(user_id,user_pwd);
    }

    /**
     * 修改用户
     */
    @ApiOperation(value = "修改用户")
    @PutMapping(value = "/")
    public Message<?> updateByUserId(User user){
        return userService.updateByPrimaryKey(user);
    }

    /**
     * 删除用户
     */
    @ApiOperation(value = "删除用户")
    @DeleteMapping(value = "/")
    public Message<?> deleteByDownloadId(String userId){
        return userService.deleteByPrimaryKey(userId);
    }

    /**
     * 根据ID用户查询
     */
    @ApiOperation(value = "根据ID用户查询")
    @GetMapping(value = "/login/userinfo")
    public Message<?> userinfo(String userId){
        return userService.selectByPrimaryKey(userId);
    }





}
